package docker

import (
	"context"
	. "pdocker/config"

	"github.com/docker/docker/client"
	log "github.com/sirupsen/logrus"
)

var (
	Ctx context.Context
	Cli *client.Client
)

func init() {
	Ctx = context.Background()
	Cli = initClient()
}
func initClient() *client.Client {
	cli, err := client.NewClientWithOpts(client.WithHost(Config.Docker.Engine),
		client.FromEnv, client.WithVersion("1.40")) //
	if err != nil {
		panic(err)
	} else {
		log.Printf("Docker API Version: %s\t\n", cli.ClientVersion())
	}
	return cli
}
